﻿using System;
using System.Windows.Forms;
using AccessControl.Management.Form;
using AccessControl.Management.Properties;


namespace AccessControl.Management
{
    public static class NotifyIconUtil
    {
        private static NotifyIcon icon;

        public static void Initializ()
        {
            icon = new NotifyIcon
            {
                Icon = Resources.Icon,
                Text = @"سیستم کنترل تردد آریابان",
                Visible = true
            };
            icon.DoubleClick += delegate
                          {
                              
                          };

            icon.ContextMenu = CreateContexMenu();
        }

        public static void ShowPopUp(String text, ToolTipIcon toolTipIcon)
        {
            icon.BalloonTipText = text;
            icon.BalloonTipTitle = @"سیستم کنترل تردد آریابان"; ;
            icon.BalloonTipIcon = toolTipIcon;
            icon.ShowBalloonTip(10000);
        }

        private static ContextMenu CreateContexMenu()
        {
            var contextMenu = new ContextMenu();
            var menuItemWindowsServiceManager = new MenuItem("مدیریت سرویس ویندوز");
            menuItemWindowsServiceManager.Click += ShowWindowsServiceManager; ;
            menuItemWindowsServiceManager.Enabled = false;

            var menuItemAddPerson = new MenuItem("مدیریت افراد");
            menuItemAddPerson.Click += ShowAddPerson; ;
            
            var menuItemExit = new MenuItem("خروج");
            menuItemExit.Click += ExitApplication;

            contextMenu.MenuItems.Add(menuItemAddPerson);
            contextMenu.MenuItems.Add(menuItemWindowsServiceManager);

            contextMenu.MenuItems.Add(menuItemExit);
            return contextMenu;

        }

        private static void ShowWindowsServiceManager(Object sender, EventArgs e)
        {
        }

        private static void ShowAddPerson(Object sender, EventArgs e)
        {
            ViewAllPerson.GetInstance().Show();

        }

        private static void ExitApplication(Object sender, EventArgs e)
        {
            Application.Exit();

        }
    }
}